package gui_layer;

import java.util.Set;
import java.util.TreeSet;

import javax.swing.table.DefaultTableModel;

@SuppressWarnings("serial")
public class MyTableModel extends DefaultTableModel
{
	private Set<Integer> editable_columns;

	public MyTableModel(Object[][] filling, String[] column_names)
	{
		super(filling, column_names);
		editable_columns = new TreeSet<Integer>();
	}
	
	public void add_editable_column(int i)
	{
		editable_columns.add(i);
	}
	
	public void remove_editable_column(int i)
	{
		editable_columns.remove(i);
	}

	public Class<?> getColumnClass(int c)
	{
		if (getRowCount() == 0 || getValueAt(0, c) == null)
		{
			return String.class;
		}
		else
		{
			return getValueAt(0, c).getClass();
		}
	}

	public boolean isCellEditable(int row, int col)
	{
		if(editable_columns.contains(col))
		{
			return true;
		}
		return false;
	}
}